
#include "mpi_lib.h"
#include "sample_vout.h"
#include "sample_cap.h"

extern mpi_mem_map_table_s g_mem_map_table[];

int sgks_mpi_sample_EnableMjpegCap(int width, int height,int rescale_width, int rescale_height)
{
    int ret = 0;
	
	sgks_mpi_vdec_init_Param_s  vdec_Param;

    vdec_Param.file_info.type					= SGKS_VDEC_TYPE_MJPEG;
    vdec_Param.file_info.width					= width;
    vdec_Param.file_info.height					= height;

    vdec_Param.vdec_buff.buff_ptr_phy			= g_mem_map_table[bsb_buff].phy_addr;
    vdec_Param.vdec_buff.size					= g_mem_map_table[bsb_buff].size;

	//only h264 vdec
    vdec_Param.rescale_sub_num					= 1;
    vdec_Param.rescale_sub[0].stream_id			= 0;
    vdec_Param.rescale_sub[0].width				= rescale_width;
    vdec_Param.rescale_sub[0].height			= rescale_height;

    ret = sgks_mpi_vdec_Enable(&vdec_Param);
    if (ret < 0)
    {
        return -1;
    }

	return SGKS_SUCCESS;
}


int sgks_mpi_sample_EnableH264Cap(int width, int height)
{
    int ret = 0;
	
	sgks_mpi_vdec_init_Param_s  vdec_Param;
    sgks_mpi_vdec_stop_Param_s  vdec_stop_Param;

    vdec_Param.file_info.type					= SGKS_VDEC_TYPE_H264;
    vdec_Param.file_info.width					= width;
    vdec_Param.file_info.height					= height;

    vdec_Param.vdec_buff.buff_ptr_phy			= g_mem_map_table[bsb_buff].phy_addr;
    vdec_Param.vdec_buff.size					= g_mem_map_table[bsb_buff].size;

    ret = sgks_mpi_vdec_Enable(&vdec_Param);
    if (ret < 0)
    {
        return -1;
    }

	return SGKS_SUCCESS;
}


int sgks_mpi_sample_CapInit(u32 cap_type, u32 rescale_yuv_type, u32 rescale_width,u32 rescale_height)
{
	int ret = SGKS_SUCCESS;
	
    sgks_mpi_cap_init_param_s cap_init_param;
	cap_init_param.cap_type = cap_type;

    memset(&cap_init_param.yuv_rescale,0,sizeof(sgks_mpi_cap_init_param_s));

	if (cap_type == SGKS_CAP_YUV_SOURCE_TYPE_VIN_RESCALE)
    {
       cap_init_param.yuv_rescale.yuv_type = (sgks_cap_yuv_semiplanar_e)rescale_yuv_type;
	   cap_init_param.yuv_rescale.width = rescale_width;
	   cap_init_param.yuv_rescale.height = rescale_height;	  
    }
   
	ret = sgks_mpi_cap_Init(&cap_init_param);
    if (ret < 0)
    {
        return -1;
    }	
	return ret;
}


